home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Animation Wizard.dir / 00014_Script_CastMgr < prev    next >
Text File  |  1997-05-10  |  4KB  |  123 lines

  1. -- CastMgr script
  2.  
  3. on birth me
  4.   return me
  5. end birth
  6.  
  7.  
  8. on mFindFreeCastRun me, howMany, startIndex
  9.   global gDevelopmentFlag
  10.   -- finds the first available run of "n" empty castmembers in the 
  11.   -- specified "cast", starting at the offset designated by "index"
  12.   
  13.   if gDevelopmentFlag then
  14.     set castNumberToStartLooking = 400  -- So I can find and delete generated cast members during dev.
  15.   else
  16.     set castNumberToStartLooking  = startIndex
  17.   end if
  18.   
  19.   -- find a run of "howMany" empty castmember slots
  20.   repeat while  TRUE
  21.     tell the stage   
  22.       -- castLib 1 is the internal cast of the stage movie
  23.       set startEmptyRun = findEmpty( member castNumberToStartLooking of castLib 1)      
  24.     end tell
  25.     if howMany = 1 then  -- Short curcuit for simple case
  26.       return startEmptyRun
  27.     end if
  28.     
  29.     set OKRunFlag = TRUE
  30.     repeat with nextCastMember = (startEmptyRun + 1) to (startEmptyRun + howMany - 1)   
  31.       if nextCastMember = 32000 then
  32.         alert("There is not enough free space in your cast to create this auto-animation.  Delete any unused castmembers and try again." )        
  33.         return 0
  34.       end if
  35.       tell the stage   
  36.         set nextEmpty = findEmpty( member nextCastMember of castLib 1)      
  37.       end tell
  38.       if nextEmpty <> nextCastMember then 
  39.         set castNumberToStartLooking = nextCastMember
  40.         set OKRunFlag = FALSE
  41.         exit repeat
  42.       end if
  43.     end repeat
  44.     if OKRunFlag then
  45.       return startEmptyRun  -- Got it, outa here
  46.     end if
  47.   end repeat  
  48.   
  49. end mFindFreeCastRun
  50.  
  51.  
  52. on  mModifyRichTextCM me, theText, theFont, theSize
  53.   set theCastName = "RichText" && theFont && theSize
  54.   set theCastNum = the number of member theCastName
  55.   if theCastNum < 1 then
  56.     alert("Internal error: mModifyRichTextCM could not find" && theCastName)
  57.     return 0
  58.   end if
  59.   set the text of member theCastNum = theText
  60.   return theCastNum
  61. end mModifyRichTextCM
  62.  
  63.  
  64. -- No longer called
  65. on mGetTextWidth me, theCastNum
  66.   set theName = the name of member theCastNum
  67.   set theFontNameAndSize = word 2 of theName & word 3 of theName
  68.   set saveText = the text of member theCastNum  -- save away original
  69.   
  70.   case theFontNameAndSize of 
  71.     "Helvetica24":  set theMWidth = 20
  72.     "Times24":  set theMWidth = 22
  73.     "Palatino24":  set theMWidth = 21
  74.     "Courier24":  set theMWidth = 23
  75.     "HelveticaBold24":  set theMWidth = 24
  76.     "TimesBold24":  set theMWidth = 25
  77.     "PalatinoBold24":  set theMWidth = 14
  78.     "CourierBold24":  set theMWidth = 15
  79.     "Arial24":  set theMWidth = 20
  80.     "TimesNewRoman24":  set theMWidth = 21
  81.     "CourierNew24":  set theMWidth = 14
  82.     "ArialBold24":  set theMWidth = 24
  83.     "TimesNewRomanBold24":  set theMWidth = 23
  84.     "CourierNewBold24":  set theMWidth = 15
  85.     otherwise alert("Internal error, mGetTextwidth could find find :" & theFontNameAndSize)
  86.   end case
  87.   
  88.   
  89.   set originalHeight = the height of member theCastNum
  90.   set extraMs = 0
  91.   repeat while the height of member theCastNum = originalHeight
  92.     set extraMs = extraMs + 1
  93.     set the text of member theCastNum = (the text of member theCastNum) & "M"
  94.   end repeat
  95.   set extraMs = extraMs - 1
  96.   set fieldWidth = the width of member theCastNum
  97.   set sizeOfExtraMs = extraMs * theMWidth
  98.   set theRealWidth = fieldWidth - sizeOfExtraMs
  99.   
  100.   set the text of member theCastNum = saveText -- restore original
  101.   
  102.   
  103.   return theRealWidth
  104. end mGetTextWidth
  105.  
  106.  
  107.  
  108.  
  109. -- No longer called
  110. on mGetTextHeight me, theCastNum
  111.   -- The rect of a cast member gives you the size
  112.   -- of the text in the cast member.   Item 4 is the 
  113.   -- bottom, which is also the height
  114.   set theRect = the rect of member theCastNum
  115.   set theRectString = string(theRect)
  116.   set theWidthString = item 4 of theRectString
  117.   set theWidth = value(theWidthString)  
  118.   return theWidth
  119. end mGetTextHeight
  120.  
  121.  
  122.  
  123.